package dtd.PHS.VND_ExchangeRate;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.widget.ImageView;
import android.widget.TableLayout;
import android.widget.TableRow;
import android.widget.TextView;
import dtd.PHS.VND_ExchangeRate.VCB_ERate.MyCurrency;

public class RowItem extends TableRow{

	private ImageView ivFlag;
	private TextView tvBuyingRate,tvSellingRate,tvTransferRate;
	private TableRow RowItem_tmp02,RowItem_tmp04,RowItem_tmp06;
	private TextView RowItem_tmp03,RowItem_tmp05,RowItem_tmp07;
	private TableLayout RowItem_tmp01;

	public RowItem(Context context) {
		super(context);
		initRowItem();
	}

	public RowItem(Context context,AttributeSet attributes) {
		super(context,attributes);
		initRowItem();
	}

	private void initRowItem() {
		String service = Context.LAYOUT_INFLATER_SERVICE;
		LayoutInflater li = (LayoutInflater) getContext().getSystemService(service);
		li.inflate(R.layout.row_item, this, true);

		this.setLongClickable(true);

		this.ivFlag = (ImageView) findViewById(R.id.ivFlag);
		this.ivFlag.setLongClickable(true);
		
		this.tvBuyingRate = (TextView) findViewById(R.id.tvBuyingRate);
		this.tvBuyingRate.setLongClickable(true);
		
		this.tvTransferRate = (TextView) findViewById(R.id.tvTransferRate);
		this.tvTransferRate.setLongClickable(true);
		
		this.tvSellingRate = (TextView) findViewById(R.id.tvSellingRate);
		this.tvSellingRate.setLongClickable(true);
		
		this.RowItem_tmp01 = (TableLayout)findViewById(R.id.RowItem_tmp01);
		this.RowItem_tmp01.setLongClickable(true);
		
		this.RowItem_tmp02 = (TableRow)findViewById(R.id.RowItem_tmp02);
		this.RowItem_tmp02.setLongClickable(true);
		
		this.RowItem_tmp04 = (TableRow)findViewById(R.id.RowItem_tmp04);
		this.RowItem_tmp04.setLongClickable(true);
		
		this.RowItem_tmp06 = (TableRow)findViewById(R.id.RowItem_tmp06);		
		this.RowItem_tmp06.setLongClickable(true);
		
		this.RowItem_tmp03 = (TextView)findViewById(R.id.RowItem_tmp03); 
		this.RowItem_tmp03.setLongClickable(true);
		
		this.RowItem_tmp05 = (TextView)findViewById(R.id.RowItem_tmp05); 
		this.RowItem_tmp05.setLongClickable(true);
		
		this.RowItem_tmp07 = (TextView)findViewById(R.id.RowItem_tmp07); 
		this.RowItem_tmp07.setLongClickable(true);
		
	}

	public void setFlag(MyCurrency c) {
		this.ivFlag.setImageResource((int)MyUtility.mapCurrency2ResourceID.get(c));
	}

	public void setBuyingRate(String rate) {
		this.tvBuyingRate.setText(rate);
	}

	public void setSellingRate(String rate) {
		this.tvSellingRate.setText(rate);
	}

	public void setTransferRate(String rate) {
		this.tvTransferRate.setText(rate);
	}

	public void setTags(MyCurrency c) {
		String cstr = c.toString();
//Don't remove the following commented codes, it may be used in later versions
//		this.tvBuyingRate.setTag(cstr);
//		this.tvSellingRate.setTag(cstr);
//		this.tvTransferRate.setTag(cstr);
//		this.ivFlag.setTag(cstr);
//
//		this.RowItem_tmp01.setTag(cstr);
//		this.RowItem_tmp02.setTag(cstr);
//		this.RowItem_tmp03.setTag(cstr);
//		this.RowItem_tmp04.setTag(cstr);
//		this.RowItem_tmp05.setTag(cstr);
//		this.RowItem_tmp06.setTag(cstr);
//		this.RowItem_tmp07.setTag(cstr);
		
		this.setTag(cstr);

	}


}

